﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EMath.Controls.Geometry {
    /// <summary>
    /// Interaction logic for Stereometrics.xaml
    /// </summary>
    public partial class Stereometrics : UserControl {
        public Stereometrics( ) {
            InitializeComponent( );
        }

		private void Back(object sender, RoutedEventArgs e) {
			if (this.Parent is UIElement)
				(this.Parent as UIElement).Visibility = System.Windows.Visibility.Hidden;
		}

		private void CB_var1_SelectedIndexChanged(object sender, SelectionChangedEventArgs e) {
			this.Bu_Calc.IsEnabled = false;
			this.WP_Vars.Visibility = Visibility.Collapsed;
			//this.FClear( );
			this.CB_var3.IsEnabled = false;
			this.CB_var2.Items.Clear( );
			this.CB_var2.Items.Add("trójkąta");
			this.CB_var2.Items.Add("trapezu");
			this.CB_var2.Items.Add("równoległoboku");
			this.CB_var2.Items.Add("prostokąta");
			this.CB_var2.Items.Add("rombu");
			this.CB_var2.Items.Add("kwadratu");
			this.CB_var2.Items.Add("deltoidu");
			this.CB_var2.Items.Add("elipsy");
			this.CB_var2.Items.Add("koła");
			this.CB_var2.SelectedIndex = 0;
			this.CB_var2.IsEnabled = true;
			//MyGeometry.ResetDANE( );
		}
		private void CB_var2_SelectedIndexChanged(object sender, SelectionChangedEventArgs e) {
			this.Bu_Calc.IsEnabled = false;
			this.WP_Vars.Visibility = Visibility.Collapsed;
			this.CB_var3.Items.Clear( );
			if (this.CB_var2.SelectedIndex == 0) {
				this.CB_var3.Items.Add("zwykłego");
				this.CB_var3.Items.Add("równoramiennego");
				this.CB_var3.Items.Add("równobocznego");
			}
			if (this.CB_var3.Items.Count > 0) {
				this.CB_var3.SelectedIndex = 0;
				this.CB_var3.IsEnabled = true;
			} else {
				this.CB_var3.IsEnabled = false;
			//	this.FShow(CB_var1.SelectedIndex, CB_var2.SelectedIndex, CB_var3.SelectedIndex);
				this.WP_Vars.Visibility = Visibility.Visible;
			}
			//MyGeometry.ResetDANE( );
		}
		private void CB_var3_SelectedIndexChanged(object sender, SelectionChangedEventArgs e) {
			int ix = (2 - this.CB_var1.SelectedIndex) * 9;
			this.Bu_Calc.IsEnabled = false;
			if (this.CB_var2.SelectedIndex == 0 + ix && this.CB_var3.SelectedIndex == 3) {
				this.CB_var2.SelectedIndex = 1 + ix;
			} else if (this.CB_var2.SelectedIndex == 4 + ix && this.CB_var3.SelectedIndex == 8) {
				this.CB_var2.SelectedIndex = 5 + ix;
			} else {
			//	this.FShow(CB_var1.SelectedIndex, CB_var2.SelectedIndex, CB_var3.SelectedIndex);
				this.WP_Vars.Visibility = Visibility.Visible;
			}
			//MyGeometry.ResetDANE( );
		}
		private void TB_V_N_TextChanged(object sender, TextChangedEventArgs e) {
			//if (sender is TextBox)
			//	if ((sender as TextBox).Parent is Grid)
			//		if (((sender as TextBox).Parent as Grid).IsVisible)
			//			this.FCheck((int)this.CB_var1.SelectedIndex, (int)this.CB_var2.SelectedIndex, (int)this.CB_var3.SelectedIndex, sender);
		}
		private void Bu_Calc_Click(object sender, EventArgs e) {
			//FCalc(this.CB_var1.SelectedIndex, this.CB_var2.SelectedIndex, this.CB_var3.SelectedIndex);
		}
		private void PB_Image_Click(object sender, MouseButtonEventArgs e) {
			//FImage(this.CB_var1.SelectedIndex, this.CB_var2.SelectedIndex, this.CB_var3.SelectedIndex);
		}
    }
}